package com.hkbigdata.sybx.controller;

import com.hkbigdata.sybx.service.UserNameService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author yangjing
 * @creat 2025-06-04-14:15
 * @email 3010335359@qq.com
 */

@RestController
@RequestMapping("/api/userName")
public class UserNameController {

    private final UserNameService userNameService;

    public UserNameController(UserNameService userNameService) {
        this.userNameService = userNameService;
    }

    /**
     * 根据用户ID获取用户名
     * @param userId 用户ID
     * @return JSON格式的结果
     */
    @GetMapping("/{userId}")
    public Map<String, Object> getUserNameByUserId(@PathVariable String userId) {
        return userNameService.getUserNameByUserId(userId);
    }


}
